﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Composite.Regions;

using DataflowListModule.Views.DataflowListView;
using ELMWCFServiceClass.ELMWCF;
using ELMApplication.Common.Const;
using DataflowListModule.Views.NewDataflowView;

namespace DataflowListModule
{
    public class DataflowListModule:IModule
    {
        private readonly IUnityContainer container;
        private readonly IRegionManager regionManager;
        public DataflowListModule(IUnityContainer container, IRegionManager regionManager)
        {
            this.regionManager = regionManager;
            this.container = container;
        }

        #region IModule Members

        public void Initialize()
        {
            registerViewsAndServices();
            regionManager.RegisterViewWithRegion(RegionNames.DataListRegion.ToString(), () => container.Resolve<IDataflowListPresentationModel>().View);
            //regionManager.Regions[RegionNames.DataListRegion.ToString()].Add(container.Resolve<IDataflowListPresentationModel>().View, "DataflowListView");
            regionManager.Regions[RegionNames.NewMessageRegion.ToString()].Add(container.Resolve<INewDataflowPrentationModel>().View, "NewDataflowView");

        }

        protected void registerViewsAndServices()
        {


            container.RegisterType<ELMServiceClient>(new InjectionConstructor());
            container.RegisterType<IDataflowListView, DataflowListView>();
            container.RegisterType<IDataflowListPresentationModel, DataflowListPrentationModel>();
            container.RegisterType<INewDataflowView, NewDataflowView>();
            container.RegisterType<INewDataflowPrentationModel, NewDataflowPrentationModel>();

        }


        #endregion
    }
}
